package org.mercworks.igamexmlparser;

import org.mercworks.igamexmlparser.dvo.IGameModel;
import org.mercworks.igamexmlparser.util.IGameModelConverter;
import org.mercworks.igamexmlparser.util.ModelExporter;
import org.mercworks.knightgame.model.KnightGameModel;

public class IGameXmlParserMain
{
	public static void main(String args[])
	{
		if(args.length == 0)
			System.out.println("You must pass the xml filename as an argument.");
		else
		{
			IGameXmlParser iGameXmlParser = new IGameXmlParser(args[0]);
			IGameModel iGameModel = iGameXmlParser.getXmlObject();
			System.out.println(iGameModel);
			
			System.out.println("*** CONVERTING RESULTS ABOVE INTO A USEABLE KNIGHT GAME MODEL ***");
			KnightGameModel kgModel = IGameModelConverter.convertToKnightGameModel(iGameModel);
			System.out.println("*** SUCCESSFULLY CONVERTED ***");
			
			try
			{
				System.out.println("*** EXPORTING KNIGHT GAME MODEL TO FILE ***");
				ModelExporter.exportModel(kgModel);
				System.out.println("*** SUCCESSFULLY EXPORTED ***");
			}
			catch(Exception ex)
			{
				ex.printStackTrace();
			}
		}
	}
}
